package com.xiaoc.bulldozer.common;

import com.google.common.collect.Maps;
import com.xc.framework.common.utils.NumberUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FormRecordConstant {



    /**
     * 审核轮次数
     */
    public static final int LOAN_CHECK_ROUND_COUNT = 2;


    /**
     * 处理中
     */
    public static final int PROCESSING = 10;

    /**
     * 初审已转介
     */
    public static final int FIRST_TRIAL_OUT = 11;

    /**
     * 初审已拒绝
     */
    public static final int FIRST_TRIAL_REFUSE = 20;

    /**
     * 初审已通过
     */
    public static final int FIRST_TRIAL_PASS = 30;

    /**
     * 复审已拒绝
     */
    public static final int SECOND_TRIAL_REFUSE = 40;

    /**
     * 复审已通过
     */
    public static final int SECOND_TRIAL_PASS = 50;


    /**
     * 类型
     */
    public static class Type {

        //贷款
        public static final int LOAN = 10;

        //信用卡
        public static final int CREDIT_CARD = 20;
    }

    /**
     * 来源
     */
    public static class Source {

        //小程序
        public static final int MIN_APP = 10;

        //PC
        public static final int PC = 20;
    }


    /**
     * 初审状态
     */
    public static final List<Integer> FIRST_TRIAL_LIST = new ArrayList<>();

    static {
        FIRST_TRIAL_LIST.add(FIRST_TRIAL_OUT);
        FIRST_TRIAL_LIST.add(FIRST_TRIAL_REFUSE);
        FIRST_TRIAL_LIST.add(FIRST_TRIAL_PASS);
    }

    /**
     * 复审状态
     */
    public static final List<Integer> SECOND_TRIAL_LIST = new ArrayList<>();

    static {
        SECOND_TRIAL_LIST.add(SECOND_TRIAL_REFUSE);
        SECOND_TRIAL_LIST.add(SECOND_TRIAL_PASS);
    }

    /**
     * 状态Map
     *
     */
    public static final Map<Integer, List<Integer>> FORM_RECORD_STATUS_MAP = Maps.newHashMap();

    static {
        FORM_RECORD_STATUS_MAP.put(1, FIRST_TRIAL_LIST);

        FORM_RECORD_STATUS_MAP.put(2,SECOND_TRIAL_LIST);
    }


    public enum FormRecordStatus {

        //物料海报对应关系
        PROCESSING(10, "待处理"), FIRST_TRIAL_OUT(11, "初审已转介"), FIRST_TRIAL_REFUSE(20, "初审已拒绝"), FIRST_TRIAL_PASS(30, "初审已通过"),

        SECOND_TRIAL_REFUSE(40, "复审已拒绝"), SECOND_TRIAL_PASS(50, "复审已通过");

        private int index;

        private String name;

        private FormRecordStatus(int index, String name) {
            this.index = index;
            this.name = name;
        }


        public static String getStatusName(Integer index) {
            FormRecordStatus[] statuses = values();
            for (FormRecordStatus status : statuses) {
                if (NumberUtil.equals(status.index, index)) {
                    return status.name;
                }
            }
            return null;
        }

        public static List<Integer> getAllKey() {
            List<Integer> keys = new ArrayList<>();
            FormRecordStatus[] statuses = values();
            for (FormRecordStatus status : statuses) {
                keys.add(status.index);
            }
            return keys;
        }


        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }


    public enum LoanCheckType {

        FIRST(1, "初审"), SECOND(2, "复审");

        private int index;

        private String name;

        private LoanCheckType(int index, String name) {
            this.index = index;
            this.name = name;
        }


        public static String getLoanCheckTypeName(Integer index) {
            LoanCheckType[] statuses = values();
            for (LoanCheckType loanCheckType : statuses) {
                if (NumberUtil.equals(loanCheckType.index, index)) {
                    return loanCheckType.name;
                }
            }
            return null;
        }

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }


    public static final Map<Integer, String> LOAN_MSG_MAP = new HashMap<>();

    static {
        LOAN_MSG_MAP.put(PROCESSING, ConfigKeys.LOAN_COMMIT_MSG);

        LOAN_MSG_MAP.put(FIRST_TRIAL_REFUSE, ConfigKeys.LOAN_FIRST_REFUSE_MSG);
        LOAN_MSG_MAP.put(FIRST_TRIAL_OUT, ConfigKeys.LOAN_OUT_MSG);
        LOAN_MSG_MAP.put(FIRST_TRIAL_PASS, ConfigKeys.LOAN_FIRST_PASS_MSG);

        LOAN_MSG_MAP.put(SECOND_TRIAL_REFUSE, ConfigKeys.LOAN_SECOND_REFUSE_MSG);
        LOAN_MSG_MAP.put(SECOND_TRIAL_PASS, ConfigKeys.LOAN_SECOND_PASS_MSG);
    }


    public static final Map<Integer, String> LOAN_MSG_MANAGER_MAP = new HashMap<>();

    static {
        LOAN_MSG_MANAGER_MAP.put(PROCESSING, ConfigKeys.LOAN_COMMIT_MANAGER_MSG);

        LOAN_MSG_MANAGER_MAP.put(FIRST_TRIAL_REFUSE, ConfigKeys.LOAN_FIRST_REFUSE_MANAGER_MSG);
        LOAN_MSG_MANAGER_MAP.put(FIRST_TRIAL_OUT, ConfigKeys.LOAN_OUT_MANAGER_MSG);
        LOAN_MSG_MANAGER_MAP.put(FIRST_TRIAL_PASS, ConfigKeys.LOAN_FIRST_PASS_MANAGER_MSG);

        LOAN_MSG_MANAGER_MAP.put(SECOND_TRIAL_REFUSE, ConfigKeys.LOAN_SECOND_REFUSE_MANAGER_MSG);
        LOAN_MSG_MANAGER_MAP.put(SECOND_TRIAL_PASS, ConfigKeys.LOAN_SECOND_PASS_MANAGER_MSG);
    }
}
